import sys

import pandas as pd
import cx_Oracle

dsn = cx_Oracle.makedsn('8.141.85.230', 1521, "orcl")
connection = cx_Oracle.connect('dyyy', 'cpt123', dsn)
cursor = connection.cursor()
# 读取 CSV 文件
data = pd.read_csv('抖音竞品动销数据 -单日 - 匹配数据.csv', encoding='utf8')
# 提取列数据
product_ID = data['产品ID']
brand = data['品牌']
category = data['品类']
# 数据库连接信息

# 插入数据
insert_sql = """
    INSERT INTO 产品ID匹配品牌品类表 (产品ID, 品牌, 品类)
    VALUES (:1, :2, :3)
"""
for index, row in data.iterrows():
    cursor.execute(insert_sql, (row['产品ID'], row['品牌'], row['品类']))

# 提交事务
connection.commit()

# 关闭连接
cursor.close()
connection.close()

print("数据成功插入到表中")
